/**
 * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package coba.service.impl;

import java.util.Date;
import java.util.List;

import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.exception.SystemException;

import coba.model.ConcurrenciaRecorrido;
import coba.model.Itinerario;
import coba.model.Recorrido;
import coba.service.base.RecorridoLocalServiceBaseImpl;

/**
 * The implementation of the Recorrido local service.
 *
 * <p>
 * All custom service methods should be put in this class. Whenever methods are added, rerun ServiceBuilder to copy their definitions into the {@link coba.service.RecorridoLocalService} interface.
 *
 * <p>
 * This is a local service. Methods of this service will not have security checks based on the propagated JAAS credentials because this service can only be accessed from within the same VM.
 * </p>
 *
 * @author rodri042
 * @see coba.service.base.RecorridoLocalServiceBaseImpl
 * @see coba.service.RecorridoLocalServiceUtil
 */
public class RecorridoLocalServiceImpl extends RecorridoLocalServiceBaseImpl {

	public Recorrido add(String nombre, long capacidad, String mails, long usuarioAlta)
			throws SystemException {

		Recorrido recorrido = recorridoPersistence.
				create(counterLocalService.increment(Recorrido.class.getName()));

		recorrido.setNombre(nombre);
		recorrido.setCapacidad(capacidad);
		recorrido.setMails(mails);
		recorrido.setFechaAlta(new Date());
		recorrido.setUsuarioAlta(usuarioAlta);

		return super.addRecorrido(recorrido);
		
	}

	public Recorrido update(long id, String nombre, long capacidad, String mails)
			throws SystemException, PortalException {

		Recorrido recorrido = this.getRecorrido(id);

		recorrido.setNombre(nombre);
		recorrido.setCapacidad(capacidad);
		recorrido.setMails(mails);

		return super.updateRecorrido(recorrido);
		
	}

	public Recorrido baja(long recorridoId, long usuarioBaja)
			throws SystemException, PortalException {

		Recorrido recorrido = this.getRecorrido(recorridoId);
		
		recorrido.setFechaBaja(new Date());
		recorrido.setUsuarioBaja(usuarioBaja);
		
		return super.updateRecorrido(recorrido);

	}

	public List<Recorrido> findByNombreAndFechaBaja(String nombre, Date fechaBaja) throws SystemException {
		return recorridoPersistence.findByNombreAndFechaBaja(nombre, fechaBaja);
	}

	public List<Recorrido> findByFechaBaja(Date fechaBaja) throws SystemException {
		return recorridoPersistence.findByFechaBaja(fechaBaja);
	}

	public int countByFechaBaja(Date fechaBaja) throws SystemException {
		return recorridoPersistence.countByFechaBaja(fechaBaja);
	}

	public List<Recorrido> findByFechaBaja(Date fechaBaja, int start, int end) throws SystemException {
		return recorridoPersistence.findByFechaBaja(fechaBaja, start, end);
	}

}
